<script type="text/javascript">
	$(function() {
		var type = "";
		$.post("applicationSingle/getinfoByApplicationRegister", function(data) {
			$(data).each(function(n, item) {
				$("#cardpName").val(item.AppParm.cardpName);
				$("#cardCode").val(item.AppParm.cardpCode);//隐藏域记录code
				$("#cardType").val(item.AppParm.cardType);
				//20180202 惠国磊 以下一行 修改 
				$("#cardTypeCode").val(item.AppParm.cardTypeCode);//隐藏域记录code
				$("#paperType").val(item.AppParm.paperType);
				$("#paperTypeCode").val(item.AppParm.paperTypeCode);//隐藏域记录code
				$("#paperNo").val(item.AppParm.paperNO);
				if(item.Personal!=null&&item.Personal.birthday!=null){
					$("#birth").val(getDate(item.Personal.birthday));
				}
				//$("#submitApplication").attr("disabled",true); 
				var path="";
				if(typeof(item.path) != "undefined"){
					path=item.path;
				}else{
					path="./themes/default/images/default.png"
				}
				$("#photo").html("<img style='border-style: solid;border-color: #E5EDEF;border-width: 3px' width='72' height='80' alt='查看图片'src="+path+">")
				/*  var options={"width":"100","height":"100"};
				$.pdialog.open("applicationSingle/lookPhotoIndex/"+item.AppParm.paperNO,"infos", "头像",options);
				$.pdialog.resizeDialog({style: {left: 1000, top: 100}}, $.pdialog.getCurrent(), "w");
				$.pdialog.resizeDialog({style: {left: 1000, top: 100}}, $.pdialog.getCurrent(), "n");  */
				$("#takePhotoIndex").attr("href","applicationSingle/takePhotoIndex/"+item.AppParm.paperNO+"-"+item.AppParm.paperTypeCode);
				//20180511鱼洲杰 以下一行
				$("#collectionpoint").val(item.ActiveUser.branchName);
				$("#employeeID").val(item.ActiveUser.userNo);
				
				var paperType = $("#paperType").val();
				console.log("paperType==>"+paperType);
				//判断是否之前办过卡
				if (!(item.Personal == null)) {
					//alert("exists");
					$("input[name='gender']").removeAttr("checked");
					$("#name").val(item.Personal.customerName);
					if (item.Personal.gender == 1) {
					//	alert("he is a boy");
						$("#sex1").attr("checked", true);
					} else {
					//	alert("she is a girl");
						$("#sex2").attr("checked", true);
					}
					$("#nation").val(item.Personal.nationality);
					//20180509 惠国磊  增加  以下
					var birth = new Date(item.Personal.birthday);
					console.log("生日==>"+birth.toLocaleString());
					var yyyy = birth.getFullYear();
					var mm = birth.getMonth()+1;
					if(mm<10){
						mm = "0"+mm;
					}
					var dd = birth.getDate();
					if(dd<10){
						dd="0"+dd;
					}
					$("#birth").val(yyyy+"-"+mm+"-"+dd);
					//alert(item.Personal.birthday);
					//判断有该信息不能修改
					if(!(item.Personal.mobile == null)){
					   $("#phone").val(item.Personal.mobile).attr("readonly","readonly");
					}
				}else{
					$("input[name='gender']").removeAttr("checked");
					if(paperType=="身份证" || paperType=="户口簿" || paperType=="残疾人证"){
						var genderCheck = $("#paperNo").val().substr(16,1);
						var birthYYYY = $("#paperNo").val().substr(6,4);
						var birthMM = $("#paperNo").val().substr(10,2);
						var birthDD = $("#paperNo").val().substr(12,2);
						console.log("genderCheck==>"+genderCheck);
						if(genderCheck%2==0){
						//	alert("she is a girl");
							$("#sex2").attr("checked", true);
						}else{
						//	alert("he is a boy");
							$("#sex1").attr("checked", true);
						}
						$("#birth").val(birthYYYY+"-"+birthMM+"-"+birthDD);
					} 
				}
			});
		}, "json");
		
		$("#printAction").click(function(){
			var flag;
			// A.验证数据必须项及数据格式验证
			//  a.1 获取所有必输项，class包含required
			var $required = $(".pageContent input");
			flag = validInputValue($required);
			var formData = $("form").serialize();
			formData = decodeURIComponent(formData,true);
			$("#printAction").attr("param",encodeURI(formData));
			$("#printAction").removeAttr("flag");
			$("#printAction").attr("flag",flag);
		});
	})
		
$(function(){
	$.get("applicationSingle/pro",function(data){
		var contenta="";
		
		var i;
		$(data).each(function(n,item){
                for(i=0;i<item.AddressProvince.length;i++){
                	if(item.AddressProvince[i].provinceid=='370'){
                		contenta+="<option value="+item.AddressProvince[i].provinceid+" selected>"
        				+item.AddressProvince[i].province+"</option>"
                	}else{
                		contenta+="<option value="+item.AddressProvince[i].provinceid+"> "
        				+item.AddressProvince[i].province+"</option>"
                	}
			}
			$("select[name='prAddrProvince1']").html(contenta);
			$("select[name='curAddrProvince1']").html(contenta);
			$("select[name='contactAddrProvince1']").html(contenta);
			changepro();
			changepro1();
			changepro2()
		});
	},"json");
})
function changepro(){
		var selecttext=$("select[name='prAddrProvince1']").find("option:selected").text(); 
		console.log("selecttext==>"+selecttext);
		var selectId=$("select[name='prAddrProvince1']").val();
		//document.getElementById("praddrProvince").value=selecttext;
		$("input[name='prAddrProvince']").val(selecttext);
	$.post("applicationSingle/city",{selectId:selectId},function(data){
		var contenta="<option value=''>请选择</option>";
		var i;
		$(data).each(function(n,item){
                for(i=0;i<item.AddressCity.length;i++){
                	if(item.AddressCity[i].cityid=="370700000000"){
                		contenta+="<option value="+item.AddressCity[i].cityid+" selected>"
						+item.AddressCity[i].city+"</option>"
                	}else{
                		contenta+="<option value="+item.AddressCity[i].cityid+">"
						+item.AddressCity[i].city+"</option>"
                	}
					
			}
			$("select[name='prAddrCity1']").html(contenta);
			changecitys();
		});
	},"json");
		
}
function changepro1(){
	var selectId=$("select[name='curAddrProvince1']").val();
	var selecttext=$("select[name='curAddrProvince1']").find("option:selected").text(); 
	//document.getElementById("curAddrProvince").value=selecttext;
	$("input[name='curAddrProvince']").val(selecttext);
	$.post("applicationSingle/city",{selectId:selectId},function(data){
		var contenta="<option value='' >请选择</option>";
		var i;
		$(data).each(function(n,item){
                for(i=0;i<item.AddressCity.length;i++){
                	if(item.AddressCity[i].cityid=="370700000000"){
                		contenta+="<option value="+item.AddressCity[i].cityid+" selected >"
        				+item.AddressCity[i].city+"</option>"
                	}else{
                		contenta+="<option value="+item.AddressCity[i].cityid+">"
        				+item.AddressCity[i].city+"</option>"
                	}	
			}
			$("select[name='curAddrCity1']").html(contenta);
			changecity();
		});
	},"json");
}	
function changepro2(){
	var selectId=$("select[name='contactAddrProvince1']").val();
	var selecttext=$("select[name='contactAddrProvince1']").find("option:selected").text(); 
	//document.getElementById("contactAddrProvince").value=selecttext;
	$("input[name='contactAddrProvince']").val(selecttext);
	$.post("applicationSingle/city",{selectId:selectId},function(data){
		var contenta="<option value='' >请选择</option>";
		var i;
		$(data).each(function(n,item){
                for(i=0;i<item.AddressCity.length;i++){
                	if(item.AddressCity[i].cityid=="370700000000"){
                		contenta+="<option value="+item.AddressCity[i].cityid+" selected >"
        				+item.AddressCity[i].city+"</option>"
                	}else{
                		contenta+="<option value="+item.AddressCity[i].cityid+">"
        				+item.AddressCity[i].city+"</option>"
                	}
				
			}
			$("select[name='contactAddrCity1']").html(contenta);
			changecity1();
		});
	},"json");
}
function changecitys(){
	var selecttext=$("select[name='prAddrCity1']").find("option:selected").text(); 
	//document.getElementById("prAddrCity").value=selecttext;
	$("input[name='prAddrCity']").val(selecttext);
}
function changecity(){
	var selectId=$("select[name='curAddrCity1']").val();
	if(selectId==null || selectId==""){
		return false;
	}
	var selecttext=$("select[name='curAddrCity1']").find("option:selected").text(); 
	//document.getElementById("curAddrCity").value=selecttext;
	$("input[name='curAddrCity']").val(selecttext);
	$.post("applicationSingle/county",{selectId:selectId},function(data){
		var contenta="<option value='' >请选择</option>";
		var i;
		$(data).each(function(n,item){
                for(i=0;i<item.AddressArea.length;i++){
                	if(item.AddressArea[i].areaid=="370781000000"){
                		contenta+="<option value="+item.AddressArea[i].areaid+" selected >"
        				+item.AddressArea[i].area+"</option>"
                	}else{
                		contenta+="<option value="+item.AddressArea[i].areaid+">"
        				+item.AddressArea[i].area+"</option>"
                	}
				
			}
			$("select[name='curAddrCounty1']").html(contenta);
			changecounty();
		});
	},"json");
}
function changecity1(){
	var selectId=$("select[name='contactAddrCity1']").val();
	if(selectId==null || selectId==""){
		return false;
	}
	var selecttext=$("select[name='contactAddrCity1']").find("option:selected").text(); 
	//document.getElementById("contactAddrCity").value=selecttext;
	$("input[name='contactAddrCity']").val(selecttext);
	$.post("applicationSingle/county",{selectId:selectId},function(data){
		var contenta="<option value='' >请选择</option>";
		var i;
		$(data).each(function(n,item){
                for(i=0;i<item.AddressArea.length;i++){
                	if(item.AddressArea[i].areaid=="370781000000"){
                		contenta+="<option value="+item.AddressArea[i].areaid+" selected >"
        				+item.AddressArea[i].area+"</option>"
                	}else{
                		contenta+="<option value="+item.AddressArea[i].areaid+">"
        				+item.AddressArea[i].area+"</option>"
                	}
				
			}
			$("select[name='contactAddrCounty1']").html(contenta);
			changecounty1();
		});
	},"json");
}
function changecounty(){
	var selectId=$("select[name='curAddrCounty1']").val();
	if(selectId==null || selectId==""){
		return false;
	}
	var selecttext=$("select[name='curAddrCounty1']").find("option:selected").text(); 
	//document.getElementById("curAddrCounty").value=selecttext;
	$("input[name='curAddrCounty']").val(selecttext);
	$.post("applicationSingle/area",{selectId:selectId},function(data){
		var contenta="<option value='' selected>请选择</option>";
		var i;
		$(data).each(function(n,item){
                for(i=0;i<item.AddressStreet.length;i++){
				contenta+="<option value="+item.AddressStreet[i].streetid+">"
				+item.AddressStreet[i].street+"</option>"
			}
			$("select[name='curAddrStreet1']").html(contenta);		
		});
	},"json");
}
function changecounty1(){
	var selectId=$("select[name='contactAddrCounty1']").val();
	if(selectId==null || selectId==""){
		return false;
	}
	var selecttext=$("select[name='contactAddrCounty1']").find("option:selected").text(); 
	//document.getElementById("contactAddrCounty").value=selecttext;
	$("input[name='contactAddrCounty']").val(selecttext);
	$.post("applicationSingle/area",{selectId:selectId},function(data){
		var contenta="<option value='' selected>请选择</option>";
		var i;
		$(data).each(function(n,item){
                for(i=0;i<item.AddressStreet.length;i++){
				contenta+="<option value="+item.AddressStreet[i].streetid+">"
				+item.AddressStreet[i].street+"</option>"
			}
			$("select[name='contactAddrStreet1']").html(contenta);
		
		});
	},"json");
}
function changestreet(){
	var selecttext=$("select[name='curAddrStreet1']").find("option:selected").text(); 
	//document.getElementById("curAddrStreet").value=selecttext;
	$("input[name='curAddrStreet']").val(selecttext);
}
function changestreet1(){
	var selecttext=$("select[name='contactAddrStreet1']").find("option:selected").text(); 
	//document.getElementById("contactAddrStreet").value=selecttext;
	$("input[name='contactAddrStreet']").val(selecttext);
}
$(function(){
	$.get("applicationSingle/nation",function(data){
		var contenta="<option value='' selected>请选择</option>";
		var i;
		$(data).each(function(n,item){
                for(i=0;i<item.Nation.length;i++){
                	if(item.Nation[i].nationname=="汉族"){
                		contenta+="<option value="+item.Nation[i].numbercode+" selected='selected'>"
        				+item.Nation[i].nationname+"</option>"
        				continue;
                	}
					contenta+="<option value="+item.Nation[i].numbercode+">"
								+item.Nation[i].nationname+"</option>"
			}
			$("#nationality").html(contenta);
	
			
		});
	},"json");
})
$("#submitApplication").click(function(){
	var flag=true;
	 $.ajax({
		    type: "POST",
		    url:"applicationSingle/judgementPrint",
		    //data:{"applyBatchNo":parm},
		    async : false,
		    dataType:"json",
		    success: function(json){
			if(json.statusCode==DWZ.statusCode.error){
				navTabAjaxDone(json);
				flag=false;
			}
		 },	
		}); 
	 
	 return flag;
})
</script>
<div class="pageContent">
	<form method="post" action="applicationSingle/toCharge"
		class="pageForm"
		onsubmit="return validateCallback(this, printViewPageAjaxDone);">

		<div class="pageFormContent" layoutH="56">
			<fieldset>
				<legend>个人信息</legend>
				 <div Style="width: 100%;">
					<div id="photo" style="float: right;padding-right:250px">
						
						<img  width="72" height="80" alt="查看图片" src="">
					</div>
				</div>
				
				<p>
					<label>采集网点：</label> <input id="collectionpoint"
						name="collectionpoint"  type="text" size="30"
						 alt="" readonly="readonly" />
				</p>
				<p>
					<label>员工编号：</label> <input id="employeeID" name="employeeID"
						 type="text" size="30" alt=""
						readonly="readonly" />
				</P>			
				<p>
					<label>卡产品名称：</label> <input id="cardpName" name="cardpName"
						class="field1" type="text" size="30" class="required" alt=""
						readonly="readonly" /> <input id="cardCode" name="cardCode"
						type="hidden">
				</p>
				<!-- <img id="photo" width="72" height="80" alt="查看图片" src="/qzsmk_card/uploadImages/photos/123456789.PNG"> -->
				<p>
					<label>卡类型：</label> <input id="cardType" name="cardtype"
						class="field1" type="text" size="30" class="required" alt=""
						readonly="readonly" /> <input id="cardTypeCode"
						name="cardTypeCode" type="hidden">&nbsp;&nbsp;
						<!-- <a id="lookPhotoIndex" class="" href="" target="dialog" rel="lookPhotoIndex" title="头像" width="320" height="240">查看头像</a> -->

				</P>

				<p>
					<label>姓名：</label> <input id="name" name="customerName"
						class="validRequired validName" type="text" size="10"  alt="" />
				</P>


				<p>
					<label>性别：</label> <input id="sex1" type="radio" name="gender"
						value="01" />男 <input id="sex2" type="radio" name="gender"
						value="02" />女
				</P>

				<p>
					<label>民族：</label> <select id="nationality" name="nationality"
						class="validRequired" >
						</select>
				</P>

				<p>
					<label>出生日期：</label> <input id="birth" name="birth"
						type="text" size="30" class="validRequired" readonly="readonly" />
				</P>

				<p>
					<label>证件类型：</label> <input id="paperType" name="papertype"
						type="text" size="30" class="" alt="" readonly="readonly" />
					<input id="paperTypeCode" name="paperType" type="hidden">
				</p>

				<p>
					<label>证件号码：</label> <input id="paperNo" name="paperNo" type="text"
						size="30" class="" alt="" readonly="readonly" />
				</P>
				<input name="formSeriData" type="hidden">
			</fieldset>

			<fieldset>
				<legend>户籍信息</legend>
				<p>
					<!-- 户籍地址省份 -->
					<label>户籍所在省份：</label> <select class="" name="prAddrProvince1" onchange="changepro()">
					
					</select>
					<input  name="prAddrProvince" type="hidden" value="" >
				</p>
				<p>
					<!-- 户籍地址市-->
					
					<label>户籍所在市：</label> <select class="" name="prAddrCity1"  onchange="changecitys()">	
					<option value="">请选择</option> 
					</select>
					<input name="prAddrCity" type="hidden" value="" >
				</p>
			</fieldset>
			<fieldset>
				<legend>现居住地信息</legend>
				<p>
				<label>省：</label> <select class=""  name="curAddrProvince1" onchange="changepro1()">
					
					</select>
					<input  name="curAddrProvince" type="hidden" value="" >
				</p>
				<p>
				<label>市：</label> <select class="" id="curAddrCity1" name="curAddrCity1" onchange="changecity()">
					
						<option value="">请选择</option>
					</select>
					<input name="curAddrCity" type="hidden" value="" >
				</p>
				<p>
				<label>区/县：</label> <select class=""  name="curAddrCounty1" onchange="changecounty()">
					
						<option value="">请选择</option>
					</select>
					<input  name="curAddrCounty" type="hidden" value="" >
				</p>
				<p>
				<label>街道/镇：</label> <select class=""  name="curAddrStreet1" onchange="changestreet()">
					
						<option value="">请选择</option>
					</select>
					<input name="curAddrStreet" type="hidden" value="" >
				</p>
				<p>
					<label>详细地址：</label> <input id="add" name="curAddrDetailedInfo"
						 type="text" size="30" maxlength="30" alt="" />
				</P>
			</fieldset>
			<fieldset>
				<legend>通讯地址信息：</legend>
				<p><label>省：</label> <select class=""  name="contactAddrProvince1" onchange="changepro2()">
					
					</select>
					<input  name="contactAddrProvince" type="hidden" value="" >
				</p>
				<p><label>市：</label> <select class="" name="contactAddrCity1"  onchange="changecity1()">
					
						<option value="">请选择</option>
					</select>
					<input  name="contactAddrCity" type="hidden" value="" >
				</p>
				<p>
				<label>区/县：</label> <select class="" id="contactAddrCounty1" name="contactAddrCounty1" onchange="changecounty1()">
					
						<option value="">请选择</option>
					</select>
					<input  name="contactAddrCounty" type="hidden" value="" >
				</p>
				<p>
				<label>街道/镇：</label> <select class="" 
						name="contactAddrStreet1" onchange="changestreet1()">
					
						<option value="">请选择</option>
					</select>
					<input  name="contactAddrStreet" type="hidden" value="" >
				</p>
				<p>
					<label>详细地址：</label> <input id="add" name="contactAddrDetailedInfo"
						 type="text" size="30"  maxlength="30" alt="" />
				</P>

				<p>
					<label>固定电话：</label> <input id="telephone" name="homePhone"
						 type="text" size="15"  alt="" class="validTelePhone"/>
				</P>

				<p>
					<label>联系电话(手机)：</label> 
					<input id="phone" name="mobile" 
						type="text" size="15"  maxlength="11" class="validRequired validMobile"/>
				</P>

				<p>
					<label>邮政编码：</label> <input id="postcode" name="contactPostalcode"
						 type="text" size="15" class="validPostCode"/>
				</P>

				<p>
					<label>电子邮箱：</label> <input id="email" name="email"
						 type="text" size="20" class="validEmail"/>
				</P>
			</fieldset>
			<div class="formBar">
				<ul>
					<li>
						<div class="buttonActive">
							<div class="buttonContent">
							<a id="takePhotoIndex" class="" href="" target="dialog" rel="takePhotoIndex" title="拍照" width="700" height="800">
								<button type="button">拍照</button></a>
							</div>
						</div>
					</li>
					<!-- <li>
						<div class="buttonActive">
							<div class="buttonContent">
								<button type="submit">读身份证</button>
							</div>
						</div>
					</li> -->
					<!-- 20180203 惠国磊 以下4行  修改 -->
					<li>
						<a id="printAction" class="button" href="printApplicationForm/toPdfView" target="dialog" param="" rel="applyFormPrint" max="true" title="打印申请表单"><span>打印</span></a><br /><br />
					</li>
					<!-- <li>
						<a  id="uploadApplication" class="buttonActive" href="applicationSingle/chargePage" target="dialog" rel="fileUploadIndex" title="上传文件" width="420" height="300"><span>上传</span></a><br /><br />
					</li> -->
					<li>
						<div class="buttonActive">
							<div class="buttonContent">
								<button id="submitApplication" type="submit" class="valid">提交</button>
							</div>
						</div>
					</li>
					<!-- 20180203 惠国磊 以下3行  修改 -->
					<li>
						<a class="buttonActive" href="applicationSingle/single"
						target="navTab" rel="ApplicationSingle" title="单笔申请"><span>返回</span></a>
					</li>
				</ul>
			</div>
			</div>
	</form>
</div>